// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        //duration: 0,//子弹消除时间

        //添加敌机
        enemybos: {
            type: cc.Node,
            default: null,
        },
        enemyiny: {
            type: cc.Prefab,
            default: null,
        },
        enemybos2:{
            type:cc.Node,
            default:null,
        }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad() {

    },

    start() {

    },


    onBeginContact: function (contact, selfCollider, otherCollider) {
        //this.node.destroy();
       
        //otherCollider.node.destroy();//删除飞机
        //otherCollider.node.getComponent(cc.Sprite).cc.jianxue(this.atk);
        // var jj= this.enemybos.getComponent("enemybos");
        //jj.jianxue();
        if (otherCollider.node.name == 'enemybos') {
            selfCollider.node.destroy();//删除子弹
            var xx = otherCollider.getComponent('enemybos');//取得敌机脚本
            xx.jianxue();//取得敌机脚本里的方法           
        }
        if(otherCollider.node.name=='enemybos2'){
            selfCollider.node.destroy();
            var jj=otherCollider.getComponent('enemybos2');
            jj.jianxue();
        }
    },

    // onCollisionEnter: function (other, self) {
    //         //this.node.destroy();
    //         self.node.destroy();
    //         other.node.destroy();
    // },

    update(dt) {
        // this.duration -= dt;
        // if (this.duration <= 0) {
        //     this.node.destroy();//删除当前结点（子弹）
        // }
        if(this.node.y>=1045){
            this.node.destroy();
        }
    },
});
